package net.itheima.mm.service.impl;

import net.itheima.mm.dao.CourseDao;
import net.itheima.mm.entity.QueryPageBean;
import net.itheima.mm.exception.CustomException;
import net.itheima.mm.pojo.Catalog;
import net.itheima.mm.pojo.Course;
import net.itheima.mm.service.CourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author zhangyan
 * @date 2021/2/25 19:53
 */
@Service
public class CourseServiceImpl implements CourseService {

    @Autowired
    CourseDao courseDao;

    //查询总条数 total
    @Override
    public long getTotal() {
        System.out.println("查询总条数:" + courseDao.getTotal());
        return courseDao.getTotal();
    }

    //分页查询
    @Override
    public List<Course> findListByPage(QueryPageBean queryPageBean) {

        // Integer currentPage;    // 页码
        // Integer pageSize;       // 每页记录数
        // Map queryParams;        // 查询条件
        // Integer offset;         // 分页查询，开始记录下标 (currentPage-1)*pageSize

        //查询
        List<Course> list = courseDao.findListByPage(queryPageBean);

        return list;
    }

    //新增
    @Override
    public void add(Course course) {
        courseDao.add(course);
    }

    //编辑
    @Override
    public void update(Course course) {
        courseDao.update(course);
    }

    //删除
    @Override
    public void delete(Integer id) {
        courseDao.delete(id);
    }
}
